#ifndef _LINKTREE_H_
#define _LINKTREE_H_

#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include "DoubleLinkList.h"
#define TreeElementType char*

typedef struct TreeNode TNode;
typedef struct LinkTree LTree;

TNode *CreateTreeNode(TreeElementType element);
void FreeTreeNode(void *n);
//获取节点数据域
void *GetTreeNodeData(TNode *node);

LTree *InitLinkTree();
void ClearLinkTree(void *tree);

TNode *GetTreeRoot(LTree *tree);

//链接
void ConnectBranch(TNode *parent,TNode *child);
//断开
void DisconnectBranch(TNode *parent, TNode *child);
//遍历树
void TravelTree(LTree *tree, void (*funcPtr)(void *));

//查找
TNode *FindTreeNode(TNode *node, void *value, bool (*funcPtr)(void *, void *));
TNode *FindLinkTreeNode(LTree *tree, void *value, bool (*funcPtr)(void *, void *));
//查找所有叶子节点
DLlist FindAllLeavesBranches(LTree *tree);
//得到树的高度
int GetTreeHeight(LTree *tree);
#endif